home *** CD-ROM | disk | FTP | other *** search
- (*
- RadioChat Example Extension-API Library
-
- Confidental property of Dirk Faust
- Use this as a macro for scripting your own RC-API-Extensions
- *)
-
- library sample; // Will be compiled/linked to sample.dll
-
- uses windows, sysutils;
-
- {$R *.RES}
-
- {$include RCinclude.pas}
-
- Function DLL_Show_WhereAmI(ucb:TUCB; input:PChar):Boolean; cdecl far;
- // example for RCRoomInfo & RCSendUID
- var rcb:TRCB;
- pc, pc2:PChar;
- gast:String;
- begin
- GetMem(pc, 200); // Memory for output-string
- GetMem(pc2, 200); // Memory for UID-String
- rcb:=RCRoomInfo(ucb.uraum); // Fill "rcb" with roominfo of caller (where he is)
- if rcb.superuid=ucb.uid then begin // Is caller SuperUser of room?
- gast:='<b>SuperUser</b>'; // Yep, tell him
- end else begin
- gast:='Guest'; // No, say he is only a guest here
- end;
- strpcopy(pc, '<font size=2><i>You are as '+gast+' in room '+rcb.rname+'</i></font><BR>'#10);
- strpcopy(pc2, ucb.uid);
- RCWriteUID(pc2, pc); // Write row to UID (caller - this time)
- FreeMem(pc2, 200); // Free memory
- FreeMem(pc, 200);
- result:=TRUE; // Tell the Server that we are all right.
- end;
-
- Function DLL_Punch(ucb:TUCB; input:PChar):Boolean; cdecl far;
- // example for RCSendUID & RCUIDFromName; also an exmaple for the input-string
- var SourceRow, TargetRow, SourceUID, TargetUID:PChar;
- s, target, say:String;
- i, i2:Integer;
- ch:Char;
- begin
- GetMem(SourceRow, 500); // Memory for output to caller
- GetMem(SourceUID, 500); // Memory for UID of caller
- GetMem(TargetRow, 500); // Memory for output to destination
- GetMem(TargetUID, 500); // Memory for destination UID
-
- s:=StrPas(input); // Delphi works better with strings.. convert it
- i:=1;
- target:=''; // Process input.. input may be /schlage testy [Du Sack]
- repeat // Scan string for a space ' '
- ch:=s[i];
- if ch<>' ' then target:=target+ch;
- inc(i);
- until (i>length(s)) or (ch=' '); // ok, till here we got the target-name
- if ch=' ' then inc(i);
- say:='';
- if i<=length(s) then begin // copy the rest as a sentence to send by the way
- for i2:=i to length(s) do say:=say+s[i2];
- end;
- if say='' then say:='nothing' else say:='"'+say+'"';// no sentence? - doesn't matter ;}
-
- if target<>'' then begin // is the target-name empty?
- strpcopy(SourceUID, ucb.uid); // no..
- strpcopy(TargetRow, target); // get the UID of the target-chatter
- RCUIDFromName(TargetRow, TargetUID);
- if TargetUID<>nil then if StrPas(TargetUID)<>'' then begin // only if a target found...
- strpcopy(SourceRow, '<font color="red"><i>You punch '+target+' and say '+say+'...</i></font><BR>'#10);
- RCWriteUID(SourceUID, SourceRow); //
- strpcopy(TargetRow, '<font color="red"><i>'+ucb.uname+' says '+say+' and punch you.</i></font><BR>'#10);
- RCWriteUID(TargetUID, TargetRow);
- end else begin
- // No, no targetUID could be found - say it to him!
- strpcopy(SourceRow, '<i>'+target+' is not here...</i><BR>'#10);
- RCWriteUID(SourceUID, SourceRow);
- end;
- end;
- FreeMem(TargetUID, 500);
- FreeMem(TargetRow, 500);
- FreeMem(SourceUID, 500);
- FreeMem(SourceRow, 500);
- result:=TRUE;
- end;
-
- Function DLL_AdminMessage(ucb:TUCB; input:PChar):Boolean; cdecl far;
- var pc:PChar;
- begin
- GetMem(pc, 200);
- strpcopy(pc, '<B><FONT COLOR="#'+ucb.ucolor+'">'+ucb.uname+'</FONT> (as ChatAdmin) to all:</B><FONT SIZE=4> '+UpperCase(input)+'</FONT><BR>'#10);
- RCWriteAll(pc);
- FreeMem(pc, 200);
- result:=TRUE;
- end;
-
- exports RCExtStart, // This MUST exist in every RC-Ext.API!
- DLL_AdminMessage, DLL_Punch, DLL_Show_WhereAmI;
-
- begin
- end.
-